
import * as api from './request/api';
import config from './request/config';
import { navigateTo, reLaunch, redirectTo, validatePhoneNumber, showToast, timestampToDate, requestPay, friendlyFormatTime } from './utils/index';
import local from './utils/localStorage';
// import { navigateTo } from './utils/index.js';
App({
  onLaunch() {
    this.api = api
    this.config = config
    this.navigateTo = navigateTo
    this.reLaunch = reLaunch
    this.local = local
    this.redirectTo = redirectTo
    this.validatePhoneNumber = validatePhoneNumber
    this.showToast = showToast
    this.timestampToDate = timestampToDate
    this.requestPay = requestPay
    this.friendlyFormatTime = friendlyFormatTime
    this.userinfo = local.get('userinfo')
    this.checkMpUpdate()
    //获取系统信息
    wx.getSystemInfo({
      success: res => {
        this.system = res
      }
    })
    //获取胶囊信息
    this.menu = wx.getMenuButtonBoundingClientRect()
  },
  checkMpUpdate() {
    const updateManager = wx.getUpdateManager()
    updateManager.onUpdateReady(function () {
      wx.showModal({
        title: '更新提示',
        content: '新版本已准备好，是否重启？',
        success: function (res) {
          if (res.confirm) {
            updateManager.applyUpdate()
          }
        }
      })
    })
  },
  globalData: {
    userInfo: null,
    system: 0,
    menu: 0,
  }
})
